home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
miscellaneous
/
example2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
3KB
|
99 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) Amiga C Club (ACC) */
/* -------------------------- ------------------ */
/* */
/* Manual: AmigaDOS Amiga C Club */
/* Chapter: Miscellaneous Tulevagen 22 */
/* File: Example2.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 93-09-26 */
/* Version: 1.0 */
/* */
/* Copyright 1993, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to execute "Shell" commands */
/* from a C program with the help of the "Execute() function. */
/* Include the dos library definitions: */
#include <dos/dos.h>
/* Now we include the necessary function prototype files: */
#include <clib/dos_protos.h> /* General dos functions... */
#include <clib/exec_protos.h> /* System functions... */
#include <stdio.h> /* Std functions [printf()...] */
#include <stdlib.h> /* Std functions [exit()...] */
/* Set name and version number: */
UBYTE *version = "$VER: AmigaDOS/Miscellaneous/Example2 1.0";
/* Declared our own function(s): */
/* Our main function: */
int main( int argc, char *argv[] );
/* Main function: */
int main( int argc, char *argv[] )
{
/* Store the result code here: */
BOOL ok;
/* A "BCPL" pointer to our Console Window: */
BPTR my_console;
/* Open a Console Window to which we will sent the output to: */
my_console = Open( "CON:10/40/600/150/Example2/CLOSE/WAIT", MODE_NEWFILE );
/* Have we successfully opened the Console Window? */
if( !my_console )
{
/* Error! Inform the user: */
printf( "Error! Could not open the Console Window!\n" );
/* Exit with an error code: */
exit( 20 );
}
/* Execute the "Shell" command "Dir". We do not use */
/* and "input" handler, and the "output" should be */
/* sent to our Console Window. */
ok = Execute( "C:Dir RAM:", NULL, my_console );
/* OK? */
if( ok )
printf( "The \"Shell\" command was successfully executed!\n" );
else
printf( "Error! Could not execute the \"Shell\" command!\n" );
/* Close the Console Window: (Since we have put a */
/* "Close" gadget on it and told the window to wait */
/* for the user to close it, only the "handler" */
/* will be closed. The actual window is first closed */
/* when the user selects the Close gadget.) */
Close( my_console );
/* The End! */
exit( 0 );
}